﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BL
{
    class UpdateStockBalance
    {
        

        public static dbDataContext Db
        {
            get
            {
                if (Vars.db == null)
                {
                    Vars.db = new dbDataContext();
                }
                return Vars.db;
            }
        }

        internal static void SaveMessage(string[] message)
        {

            var update = Db.tArticleStocks.SingleOrDefault(tas => tas.stockId == int.Parse(message[1])
                         && tas.stockPositionId == int.Parse(message[2])
                         && tas.articleId == int.Parse(message[3])
                         && tas.sortId == int.Parse(message[4]));

            if (update.deleted == true)
            {
                throw new NotImplementedException();
            }
            else
            {
                update.stockBalance += int.Parse(message[5]);
                Db.SubmitChanges();
            }
        }
    }
}
